﻿using Devart.Data.SQLite;
using JMI_Nucleo.Enumerador;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JMI_Nucleo.Classe
{
    public class Log
    {
        private ILogLocal dao;
        private SQLiteConnection conexao = null;
        private List<mLog> lst = null;

        public Log()
        {
            dao = new LogLocalDao();
        }

        public List<mLog> GetListaLog(DateTime DataInicio, DateTime DataFinal)
        {
            conexao = new SQLiteConnection();            

            string caminhoBD = Path.Combine(Environment.CurrentDirectory, "Logbd.db3");

            conexao.DataSource = caminhoBD;
            conexao.Open();

            lst = dao.GetListaLog(conexao, DataInicio, DataFinal);

            conexao.Close();
            return lst;
        }

        public List<mLog> GetListaLog(TipoErro Tipo)
        {
            conexao = new SQLiteConnection();

            string caminhoBD = Path.Combine(Environment.CurrentDirectory, "Logbd.db3");

            conexao.DataSource = caminhoBD;
            conexao.Open();

            lst = dao.GetListaLog(conexao, Tipo);

            conexao.Close();
            return lst; 
        }

        public List<mLog> GetListaLog(DateTime DataInicio, DateTime DataFinal, TipoErro Tipo)
        {
            conexao = new SQLiteConnection();

            string caminhoBD = Path.Combine(Environment.CurrentDirectory, "Logbd.db3");

            conexao.DataSource = caminhoBD;
            conexao.Open();

            lst = dao.GetListaLog(conexao, Tipo, DataInicio, DataFinal);

            conexao.Close();
            return lst; 
        }
    }
}
